﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="UCBasicInformation.ascx.cs"
    Inherits="CDOP.UserControls.UcBasicInformation" %>
<asp:Table runat="server" ID="tblBasicInfo">
    <asp:TableRow>
        <asp:TableCell>
            <asp:Label ID="Label31" runat="server" Text="CDOP Reference"></asp:Label>
        </asp:TableCell>
        <asp:TableCell>
            <asp:TextBox ID="txtCdopReference" runat="server">
            </asp:TextBox>
            <a href="#" id="lnkBtnCheckCdop">Check CDOP Reference Availability</a>
            <asp:RequiredFieldValidator ControlToValidate="txtCdopReference" ID="rfvCDOPReference"
                runat="server" EnableClientScript="true" ErrorMessage="First name is requied"
                Text="*" ValidationGroup="vgBasicInfo"></asp:RequiredFieldValidator>
        </asp:TableCell>
    </asp:TableRow>
    <asp:TableRow>
        <asp:TableCell>
            <asp:Label ID="Label1" runat="server" Text="CDOP ContactPointReference"></asp:Label>
        </asp:TableCell>
        <asp:TableCell>
            <asp:TextBox ID="txtContactPointReference" runat="server">
            </asp:TextBox></asp:TableCell>
    </asp:TableRow>
    <asp:TableRow>
        <asp:TableCell>
            <asp:Label ID="Label2" runat="server" Text="NHS Number"></asp:Label>
        </asp:TableCell>
        <asp:TableCell>
            <asp:TextBox ID="txtNHSNumber" runat="server">
            </asp:TextBox></asp:TableCell>
    </asp:TableRow>
    <asp:TableRow>
        <asp:TableCell>
            <asp:Label ID="Label3" runat="server" Text="First Name"></asp:Label>
        </asp:TableCell>
        <asp:TableCell>
            <asp:TextBox ID="txtFirstName" runat="server">
            </asp:TextBox></asp:TableCell>
    </asp:TableRow>
    <asp:TableRow>
        <asp:TableCell>
            <asp:Label ID="Label4" runat="server" Text="Surname"></asp:Label>
        </asp:TableCell>
        <asp:TableCell>
            <asp:TextBox ID="txtSurname" runat="server">
            </asp:TextBox></asp:TableCell>
    </asp:TableRow>
    <asp:TableRow>
        <asp:TableCell>
            <asp:Label ID="Label5" runat="server" Text="Gender"></asp:Label>
        </asp:TableCell>
        <asp:TableCell>
            <asp:DropDownList ID="ddGender" runat="server" DataSourceID="ObjectDataSourceGender"
                DataTextField="type" DataValueField="id">
            </asp:DropDownList>
            <asp:ObjectDataSource ID="ObjectDataSourceGender" runat="server" SelectMethod="GetGenderDetails"
                TypeName="CDOP.Model.CommonRepository"></asp:ObjectDataSource>
        </asp:TableCell>
    </asp:TableRow>
    <asp:TableRow>
        <asp:TableCell>
            <asp:Label ID="Label6" runat="server" Text="Date of Birth"></asp:Label>
        </asp:TableCell>
        <asp:TableCell>
            <asp:TextBox ID="txtDateofBirth" class="tcal" runat="server">
            </asp:TextBox>
            <%--  <asp:LinkButton ID="lnkBtnGetDateOfBirth" runat="server" OnClick="LnkBtnGetDateOfBirthClick">Calendar</asp:LinkButton>
            <asp:Calendar ID="calDateofBirth" runat="server" Visible="false" OnSelectionChanged="CalDateofBirthSelectionChanged">
            </asp:Calendar>--%>
        </asp:TableCell>
    </asp:TableRow>
    <asp:TableRow>
        <asp:TableCell>
            <asp:Label ID="Label7" runat="server" Text="Date of Death"></asp:Label>
        </asp:TableCell>
        <asp:TableCell>
            <asp:TextBox ID="txtDateOfDeath" class="tcal" runat="server" onchange="onDeathDateChange()">
            </asp:TextBox>
            <%--<asp:LinkButton ID="lnkBtnGetDateOfDeath" runat="server" OnClick="LnkBtnGetDateOfDeathClick">Calendar</asp:LinkButton>
            <asp:Calendar ID="calDateofDeath" runat="server" Visible="false" OnSelectionChanged="CalDateofDeathSelectionChanged">
            </asp:Calendar>--%>
            <%--   <asp:CompareValidator ID="CompareValidatorDeath" ControlToValidate="txtDateofBirth" EnableClientScript="true" SetFocusOnError="true"
                ControlToCompare="txtDateOfDeath" Type="Date" Operator="GreaterThanEqual" Text="Date of death must be later than Dat of birth"
                runat="Server" />--%>
        </asp:TableCell>
    </asp:TableRow>
    <asp:TableRow>
        <asp:TableCell>
            <asp:Label ID="Label8" runat="server" Text="Date of Notification"></asp:Label>
        </asp:TableCell>
        <asp:TableCell>
            <asp:TextBox ID="txtDateofNotification" class="tcal" runat="server">
            </asp:TextBox>
            <%-- <asp:LinkButton ID="lnkBtnDateofNotification" runat="server" OnClick="LnkBtnDateofNotificationClick">Calendar</asp:LinkButton>
            <asp:Calendar ID="calDateofNotification" runat="server" Visible="false" OnSelectionChanged="CalDateofNotificationSelectionChanged">
            </asp:Calendar>--%>
             <a href="#" id="lnkBtnCheckDates">Check the validity of the dates entered</a>
        </asp:TableCell>
    </asp:TableRow>
    <asp:TableRow>
        <asp:TableCell>
            <asp:Label ID="Label9" runat="server" Text="Address 01"></asp:Label>
        </asp:TableCell>
        <asp:TableCell>
            <asp:TextBox ID="txtAdd01" runat="server">
            </asp:TextBox></asp:TableCell>
    </asp:TableRow>
    <asp:TableRow>
        <asp:TableCell>
            <asp:Label ID="Label10" runat="server" Text="Address 02"></asp:Label>
        </asp:TableCell>
        <asp:TableCell>
            <asp:TextBox ID="txtAdd02" runat="server">
            </asp:TextBox></asp:TableCell>
    </asp:TableRow>
    <asp:TableRow>
        <asp:TableCell>
            <asp:Label ID="Label11" runat="server" Text="Address 03"></asp:Label>
        </asp:TableCell>
        <asp:TableCell>
            <asp:TextBox ID="txtAdd03" runat="server">
            </asp:TextBox></asp:TableCell>
    </asp:TableRow>
    <asp:TableRow>
        <asp:TableCell>
            <asp:Label ID="Label12" runat="server" Text="Post Code"></asp:Label>
        </asp:TableCell>
        <asp:TableCell>
            <asp:TextBox ID="txtPostCode" runat="server">
            </asp:TextBox></asp:TableCell>
    </asp:TableRow>
    <asp:TableRow>
        <asp:TableCell>
            <asp:Label ID="Label13" runat="server" Text="Local Authority"></asp:Label>
        </asp:TableCell>
        <asp:TableCell>
            <asp:DropDownList ID="ddLocalAuthority" runat="server" DataSourceID="ObjectDataSourceLocalAuthority"
                DataTextField="authority" DataValueField="id">
            </asp:DropDownList>
            <asp:ObjectDataSource ID="ObjectDataSourceLocalAuthority" runat="server" SelectMethod="GetLocalAuthorityDetails"
                TypeName="CDOP.Model.CommonRepository"></asp:ObjectDataSource>
        </asp:TableCell>
    </asp:TableRow>
    <asp:TableRow>
        <asp:TableCell>
            <asp:Label ID="Label14" runat="server" Text="If out of area which LSCB?"></asp:Label>
        </asp:TableCell>
        <asp:TableCell>
            <asp:DropDownList ID="ddWhyDeathIncluded" runat="server" DataSourceID="ObjectDataSourceWhyDeathIncluded"
                DataTextField="reason" DataValueField="id">
            </asp:DropDownList>
            <asp:ObjectDataSource ID="ObjectDataSourceWhyDeathIncluded" runat="server" SelectMethod="GetWhyDeathIncludedDetails"
                TypeName="CDOP.Model.CommonRepository"></asp:ObjectDataSource>
        </asp:TableCell>
    </asp:TableRow>
    <asp:TableRow>
        <asp:TableCell>
            <asp:Label ID="Label15" runat="server" Text="If other please state"></asp:Label>
        </asp:TableCell>
        <asp:TableCell>
            <asp:TextBox ID="txtWhyDeathIncludedOther" runat="server">
            </asp:TextBox></asp:TableCell>
    </asp:TableRow>
    <asp:TableRow>
        <asp:TableCell>
            <asp:Label ID="Label16" runat="server" Text="If other please state"></asp:Label>
        </asp:TableCell>
        <asp:TableCell>
            <asp:TextBox ID="txtLocalAuthorityOther" runat="server">
            </asp:TextBox>
        </asp:TableCell>
    </asp:TableRow>
    <asp:TableRow>
        <asp:TableCell>
            <asp:Label ID="Label17" runat="server" Text="Ethnic Group"></asp:Label>
        </asp:TableCell>
        <asp:TableCell>
            <asp:DropDownList ID="ddEthnicGroup" runat="server" DataSourceID="ObjectDataSourceddEthnicGroup"
                DataTextField="ethnicity" DataValueField="id">
            </asp:DropDownList>
            <asp:ObjectDataSource ID="ObjectDataSourceddEthnicGroup" runat="server" SelectMethod="GetEthnicGroupDetails"
                TypeName="CDOP.Model.CommonRepository"></asp:ObjectDataSource>
        </asp:TableCell>
    </asp:TableRow>
    <asp:TableRow>
        <asp:TableCell>
            <asp:Label ID="Label18" runat="server" Text="Where was the child at the time of the event or condition that led to the death?"></asp:Label>
        </asp:TableCell>
        <asp:TableCell>
            <asp:DropDownList ID="ddLocationPrior" runat="server" DataSourceID="ObjectDataSourceLocationPrior"
                DataTextField="location" DataValueField="id">
            </asp:DropDownList>
            <asp:ObjectDataSource ID="ObjectDataSourceLocationPrior" runat="server" SelectMethod="GetPriorLocationDetails"
                TypeName="CDOP.Model.CommonRepository"></asp:ObjectDataSource>
        </asp:TableCell>
    </asp:TableRow>
    <asp:TableRow>
        <asp:TableCell>
            <asp:Label ID="Label19" runat="server" Text="If other please state"></asp:Label>
        </asp:TableCell>
        <asp:TableCell>
            <asp:TextBox ID="txtocationPriorOther" runat="server">
            </asp:TextBox></asp:TableCell>
    </asp:TableRow>
    <asp:TableRow>
        <asp:TableCell>
            <asp:Label ID="Label20" runat="server" Text="Location Prior (if Hospital)"></asp:Label>
        </asp:TableCell>
        <asp:TableCell>
            <asp:DropDownList ID="ddLocationPriorIfHospital" runat="server" DataSourceID="ObjectDataSourceLocationPriorIfHospital"
                DataTextField="location" DataValueField="id">
            </asp:DropDownList>
            <asp:ObjectDataSource ID="ObjectDataSourceLocationPriorIfHospital" runat="server"
                SelectMethod="GetPriorLocationIfHospitalDetails" TypeName="CDOP.Model.CommonRepository">
            </asp:ObjectDataSource>
        </asp:TableCell>
    </asp:TableRow>
    <asp:TableRow>
        <asp:TableCell>
            <asp:Label ID="Label21" runat="server" Text="Contact at hospital: Name"></asp:Label>
        </asp:TableCell>
        <asp:TableCell>
            <asp:TextBox ID="txtHospitalContactName" runat="server">
            </asp:TextBox></asp:TableCell>
    </asp:TableRow>
    <asp:TableRow>
        <asp:TableCell>
            <asp:Label ID="Label22" runat="server" Text="Contact at hospital: Number"></asp:Label>
        </asp:TableCell>
        <asp:TableCell>
            <asp:TextBox ID="txtHospitalContactNumber" runat="server">
            </asp:TextBox></asp:TableCell>
    </asp:TableRow>
    <asp:TableRow>
        <asp:TableCell>
            <asp:Label ID="Label23" runat="server" Text="Was the death expected"></asp:Label>
        </asp:TableCell>
        <asp:TableCell>
            <asp:DropDownList ID="ddDeathExpected" runat="server" DataSourceID="ObjectDataSourceDeathExpected"
                DataTextField="status" DataValueField="id">
            </asp:DropDownList>
            <asp:ObjectDataSource ID="ObjectDataSourceDeathExpected" runat="server" SelectMethod="GetDeathExpectedDetails"
                TypeName="CDOP.Model.CommonRepository"></asp:ObjectDataSource>
        </asp:TableCell>
    </asp:TableRow>
    <asp:TableRow>
        <asp:TableCell>
            <asp:Label ID="Label24" runat="server" Text="Was the death subject to a rapid response process?"></asp:Label>
        </asp:TableCell>
        <asp:TableCell>
            <asp:DropDownList ID="ddRapidResponse" runat="server" DataSourceID="ObjectDataSourceRapidResponse"
                DataTextField="status" DataValueField="id">
            </asp:DropDownList>
            <asp:ObjectDataSource ID="ObjectDataSourceRapidResponse" runat="server" SelectMethod="GetRapidResponseDetails"
                TypeName="CDOP.Model.CommonRepository"></asp:ObjectDataSource>
        </asp:TableCell>
    </asp:TableRow>
    <asp:TableRow>
        <asp:TableCell>
            <asp:Label ID="Label25" runat="server" Text="Rapid Response Date"></asp:Label>
        </asp:TableCell>
        <asp:TableCell>
            <asp:TextBox ID="txtRapidResponseDate" runat="server" class="tcal">
            </asp:TextBox>
            <%--  <asp:LinkButton ID="lnkRapidResponseDate" runat="server" OnClick="LnkRapidResponseDateClick">Calendar</asp:LinkButton>
            <asp:Calendar ID="calRapidResponseDate" runat="server" Visible="false" OnSelectionChanged="CalRapidResponseDateSelectionChanged">
            </asp:Calendar>--%>
        </asp:TableCell>
    </asp:TableRow>
    <asp:TableRow>
        <asp:TableCell>
            <asp:Label ID="Label26" runat="server" Text="Notified Cause of Death"></asp:Label>
        </asp:TableCell>
        <asp:TableCell>
            <asp:DropDownList ID="ddNotifiedCauseofDeath" runat="server" DataSourceID="ObjectDataSourceNotifiedCauseofDeath"
                DataTextField="cause" DataValueField="id">
            </asp:DropDownList>
            <asp:ObjectDataSource ID="ObjectDataSourceNotifiedCauseofDeath" runat="server" SelectMethod="GetNotifiedCauseofDeathDetails"
                TypeName="CDOP.Model.CommonRepository"></asp:ObjectDataSource>
        </asp:TableCell>
    </asp:TableRow>
    <asp:TableRow>
        <asp:TableCell>
            <asp:Label ID="Label27" runat="server" Text="Name of GP"></asp:Label>
        </asp:TableCell>
        <asp:TableCell>
            <asp:TextBox ID="txtGpName" runat="server">
            </asp:TextBox>
        </asp:TableCell>
    </asp:TableRow>
    <asp:TableRow>
        <asp:TableCell>
            <asp:Label ID="Label28" runat="server" Text="GP Contact Number"></asp:Label>
        </asp:TableCell>
        <asp:TableCell>
            <asp:TextBox ID="txtGpContactNumber" runat="server">
            </asp:TextBox></asp:TableCell>
    </asp:TableRow>
    <asp:TableRow>
        <asp:TableCell>
            <asp:Label ID="Label29" runat="server" Text="Asylum Seeker"></asp:Label>
        </asp:TableCell>
        <asp:TableCell>
            <asp:DropDownList ID="ddAsylumSeeker" runat="server" DataSourceID="ObjectDataSourceAsylumSeeker"
                DataTextField="status" DataValueField="id">
            </asp:DropDownList>
            <asp:ObjectDataSource ID="ObjectDataSourceAsylumSeeker" runat="server" SelectMethod="GetAsylumSeekerDetails"
                TypeName="CDOP.Model.CommonRepository"></asp:ObjectDataSource>
        </asp:TableCell>
    </asp:TableRow>
    <asp:TableRow>
        <asp:TableCell>
            <asp:Label ID="Label30" runat="server" Text="Is there a police investigation in progress?"></asp:Label>
        </asp:TableCell>
        <asp:TableCell>
            <asp:DropDownList ID="ddPoliceInvestigation" runat="server" DataSourceID="ObjectDataSourcePoliceInvestigation"
                DataTextField="status" DataValueField="id">
            </asp:DropDownList>
            <asp:ObjectDataSource ID="ObjectDataSourcePoliceInvestigation" runat="server" SelectMethod="GetPoliceInvestigationDetails"
                TypeName="CDOP.Model.CommonRepository"></asp:ObjectDataSource>
        </asp:TableCell>
    </asp:TableRow>
</asp:Table>
<input type="hidden" id="hdnErrorBasic" />
<script type="text/jscript">
    $(document).ready(function () {

        $('#lnkBtnCheckDates').click(function () {
            var deathVal = $("#<%=txtDateOfDeath.ClientID%>").val();
            if (deathVal != "") {
                var deathDate = new Date(deathVal);
                var birthVal = $("#<%=txtDateofBirth.ClientID%>").val();
                if (birthVal != "") {
                    var birthDate = new Date(birthVal);
                    if (birthDate > deathDate) {
                        alert("Birth Date must be earlier than Death Date");
                        $("#<%=txtDateofBirth.ClientID%>").val("");
                        $("#<%=txtDateOfDeath.ClientID%>").val("");
                    }
                }
                var notificationVal = $("#<%=txtDateofNotification.ClientID%>").val();
                if (notificationVal != "") {
                    var notificationDate = new Date(notificationVal);
                    if (notificationDate < deathDate) {
                        alert("Notification Date must be later than Death Date");
                        $("#<%=txtDateofNotification.ClientID%>").val("");
                        $("#<%=txtDateOfDeath.ClientID%>").val("");
                    }
                }
            }
        });


        $('#lnkBtnCheckCdop').click(function () {
            var cdopId = $("#<%=txtCdopReference.ClientID%>").val();
            if (cdopId != "") {
                $.ajax({
                    type: "POST",
                    url: "Default.aspx/IsCdopReferenceAvailable",
                    data: "{'val':" + cdopId + "}",
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    success: function (status) {
                        if (!status.d) {
                            alert("The CDOP Reference Number already exists in the database");
                            $("#<%=txtCdopReference.ClientID%>").val("");
                        }
                        else {
                            alert("CDOP Reference Number is valid");
                        }
                    }
                });
            }
            else {
                alert("Enter a valid CDOP Reference Number");
            }
        });
    });
</script>
